//
//  ViewController.swift
//  CAAnmationGroup组合动画
//
//  Created by app on 2017/4/14.
//  Copyright © 2017年 app. All rights reserved.
//

import UIKit

class ViewController: UIViewController {

    
    var loginBuuton:UIButton!
    override func viewDidLoad() {

        super.viewDidLoad()
        loginBuuton = UIButton()
        loginBuuton.frame = CGRect(x: 20, y: 230, width: view.frame.width - 49, height: 40)
        loginBuuton.setTitle("登录", for: UIControlState(rawValue: 0))
        loginBuuton.backgroundColor = UIColor.red
        view.addSubview(loginBuuton)
        
        
        let rotate:CABasicAnimation = CABasicAnimation()
        rotate.keyPath = "transform.rotation"
        rotate.toValue = M_PI
        
        let scale:CABasicAnimation = CABasicAnimation()
        scale.keyPath = "transform.scale"
        scale.toValue = 0.0
        
        let move:CABasicAnimation = CABasicAnimation()
        move.keyPath = "transform.translation"
        move.toValue = NSValue(cgPoint: CGPoint(x:217,y:-230))
        
        let animationGroup:CAAnimationGroup = CAAnimationGroup()
        animationGroup.animations = [rotate,scale,move]
        animationGroup.duration = 2
        animationGroup.fillMode = kCAFillModeForwards
        animationGroup.isRemovedOnCompletion = false
        loginBuuton.layer.add(animationGroup, forKey: nil)
        
        
        
    }


}

